/**
 * Copyright (c) 2016-2021 by the respective copyright holders.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 */
package com.zsmartsystems.zigbee.dongle.ember.ezsp.structure;

import java.util.HashMap;
import java.util.Map;

/**
 * Class to implement the Ember Enumeration <b>EzspConfigId</b>.
 * <p>
 * Identifies which configuration value to read or change with getConfigurationValue and
 * setConfigurationValue.
 * <p>
 * Note that this code is autogenerated. Manual changes may be overwritten.
 *
 * @author Chris Jackson - Initial contribution of Java code generator
 */
public enum EzspConfigId {
    /**
     * Default unknown value
     */
    UNKNOWN(-1),

    /**
     * The number of packet buffers available to the stack. When set to the special value 0xFF, the
     * NCP will allocate all remaining configuration RAM towards packet buffers, such that the
     * resulting count will be the largest whole number of packet buffers that can fit into the
     * available memory.
     */
    EZSP_CONFIG_PACKET_BUFFER_COUNT(0x0001),

    /**
     * The maximum number of router neighbors the stack can keep track of. A neighbor is a node within
     * radio range.
     */
    EZSP_CONFIG_NEIGHBOR_TABLE_SIZE(0x0002),

    /**
     * The maximum number of APS retried messages the stack can be transmitting at any time.
     */
    EZSP_CONFIG_APS_UNICAST_MESSAGE_COUNT(0x0003),

    /**
     * The maximum number of non-volatile bindings supported by the stack.
     */
    EZSP_CONFIG_BINDING_TABLE_SIZE(0x0004),

    /**
     * The maximum number of EUI64 to network address associations that the stack can maintain for
     * the application. (Note, the total number of such address associations maintained by the NCP
     * is the sum of the value of this setting and the value of
     * ::EZSP_CONFIG_TRUST_CENTER_ADDRESS_CACHE_SIZE.).
     */
    EZSP_CONFIG_ADDRESS_TABLE_SIZE(0x0005),

    /**
     * The maximum number of multicast groups that the device may be a member of.
     */
    EZSP_CONFIG_MULTICAST_TABLE_SIZE(0x0006),

    /**
     * The maximum number of destinations to which a node can route messages. This includes both
     * messages originating at this node and those relayed for others.
     */
    EZSP_CONFIG_ROUTE_TABLE_SIZE(0x0007),

    /**
     * The number of simultaneous route discoveries that a node will support.
     */
    EZSP_CONFIG_DISCOVERY_TABLE_SIZE(0x0008),

    /**
     * Specifies the stack profile.
     */
    EZSP_CONFIG_STACK_PROFILE(0x000C),

    /**
     * The security level used for security at the MAC and network layers. The supported values are 0
     * (no security) and 5 (payload is encrypted and a four-byte MIC is used for authentication).
     */
    EZSP_CONFIG_SECURITY_LEVEL(0x000D),

    /**
     * The maximum number of hops for a message.
     */
    EZSP_CONFIG_MAX_HOPS(0x0010),

    /**
     * The maximum number of end device children that a router will support.
     */
    EZSP_CONFIG_MAX_END_DEVICE_CHILDREN(0x0011),

    /**
     * The maximum amount of time that the MAC will hold a message for indirect transmission to a
     * child.
     */
    EZSP_CONFIG_INDIRECT_TRANSMISSION_TIMEOUT(0x0012),

    /**
     * The maximum amount of time that an end device child can wait between polls. If no poll is heard
     * within this timeout, then the parent removes the end device from its tables.
     */
    EZSP_CONFIG_END_DEVICE_POLL_TIMEOUT(0x0013),

    /**
     * The maximum amount of time that a mobile node can wait between polls. If no poll is heard within
     * this timeout, then the parent removes the mobile node from its tables.
     */
    EZSP_CONFIG_MOBILE_NODE_POLL_TIMEOUT(0x0014),

    /**
     * The number of child table entries reserved for use only by mobile nodes.
     */
    EZSP_CONFIG_RESERVED_MOBILE_CHILD_ENTRIES(0x0015),

    /**
     * Enables boost power mode and/or the alternate transmitter output.
     */
    EZSP_CONFIG_TX_POWER_MODE(0x0017),

    /**
     * 0: Allow this node to relay messages. 1: Prevent this node from relaying messages.
     */
    EZSP_CONFIG_DISABLE_RELAY(0x0018),

    /**
     * The maximum number of EUI64 to network address associations that the Trust Center can
     * maintain. These address cache entries are reserved for and reused by the Trust Center when
     * processing device join/rejoin authentications. This cache size limits the number of
     * overlapping joins the Trust Center can process within a narrow time window (e.g. two
     * seconds), and thus should be set to the maximum number of near simultaneous joins the Trust
     * Center is expected to accommodate. (Note, the total number of such address associations
     * maintained by the NCP is the sum of the value of this setting and the value of
     * ::EZSP_CONFIG_ADDRESS_TABLE_SIZE.)
     */
    EZSP_CONFIG_TRUST_CENTER_ADDRESS_CACHE_SIZE(0x0019),

    /**
     * The size of the source route table.
     */
    EZSP_CONFIG_SOURCE_ROUTE_TABLE_SIZE(0x001A),

    /**
     * The units used for timing out end devices on their parents.
     */
    EZSP_CONFIG_END_DEVICE_POLL_TIMEOUT_SHIFT(0x001B),

    /**
     * The number of blocks of a fragmented message that can be sent in a single window.
     */
    EZSP_CONFIG_FRAGMENT_WINDOW_SIZE(0x001C),

    /**
     * The time the stack will wait (in milliseconds) between sending blocks of a fragmented
     * message.
     */
    EZSP_CONFIG_FRAGMENT_DELAY_MS(0x001D),

    /**
     * The size of the Key Table used for storing individual link keys (if the device is a Trust
     * Center) or Application Link Keys (if the device is a normal node).
     */
    EZSP_CONFIG_KEY_TABLE_SIZE(0x001E),

    /**
     * The APS ACK timeout value. The stack waits this amount of time between resends of APS retried
     * messages.
     */
    EZSP_CONFIG_APS_ACK_TIMEOUT(0x001F),

    /**
     * The duration of a beacon jitter, in the units used by the 15.4 scan parameter (((1 less than
     * duration) + 1) * 15ms), when responding to a beacon request.
     */
    EZSP_CONFIG_BEACON_JITTER_DURATION(0x0020),

    /**
     * The time the coordinator will wait (in seconds) for a second end device bind request to
     * arrive.
     */
    EZSP_CONFIG_END_DEVICE_BIND_TIMEOUT(0x0021),

    /**
     * The number of PAN id conflict reports that must be received by the network manager within one
     * minute to trigger a PAN id change.
     */
    EZSP_CONFIG_PAN_ID_CONFLICT_REPORT_THRESHOLD(0x0022),

    /**
     * The timeout value in minutes for how long the Trust Center or a normal node waits for the ZigBee
     * Request Key to complete. On the Trust Center this controls whether or not the device buffers
     * the request, waiting for a matching pair of ZigBee Request Key. If the value is non-zero, the
     * Trust Center buffers and waits for that amount of time. If the value is zero, the Trust Center
     * does not buffer the request and immediately responds to the request. Zero is the most
     * compliant behavior.
     */
    EZSP_CONFIG_REQUEST_KEY_TIMEOUT(0x0024),

    /**
     * This value indicates the size of the runtime modifiable certificate table. Normally
     * certificates are stored in MFG tokens but this table can be used to field upgrade devices with
     * new Smart Energy certificates. This value cannot be set, it can only be queried.
     */
    EZSP_CONFIG_CERTIFICATE_TABLE_SIZE(0x0029),

    /**
     * This is a bitmask that controls which incoming ZDO request messages are passed to the
     * application. The bits are defined in the EmberZdoConfigurationFlags enumeration. To see
     * if the application is required to send a ZDO response in reply to an incoming message, the
     * application must check the APS options bitfield within the incomingMessageHandler
     * callback to see if the EMBER_APS_OPTION_ZDO_RESPONSE_REQUIRED flag is set.
     */
    EZSP_CONFIG_APPLICATION_ZDO_FLAGS(0x002A),

    /**
     * The maximum number of broadcasts during a single broadcast timeout period.
     */
    EZSP_CONFIG_BROADCAST_TABLE_SIZE(0x002B),

    /**
     * The size of the MAC filter list table.
     */
    EZSP_CONFIG_MAC_FILTER_TABLE_SIZE(0x002C),

    /**
     * The number of supported networks.
     */
    EZSP_CONFIG_SUPPORTED_NETWORKS(0x002D),

    /**
     * Whether multicasts are sent to the RxOnWhenIdle=true address (0xFFFD) or the sleepy
     * broadcast address (0xFFFF). The RxOnWhenIdle=true address is the ZigBee compliant
     * destination for multicasts.
     */
    EZSP_CONFIG_SEND_MULTICASTS_TO_SLEEPY_ADDRESS(0x002E),

    /**
     * ZLL group address initial configuration.
     */
    EZSP_CONFIG_ZLL_GROUP_ADDRESSES(0x002F),

    /**
     * ZLL rssi threshold initial configuration.
     */
    EZSP_CONFIG_ZLL_RSSI_THRESHOLD(0x0030),

    /**
     * Toggles the mtorr flow control in the stack.
     */
    EZSP_CONFIG_MTORR_FLOW_CONTROL(0x0033),

    /**
     * Setting the retry queue size.
     */
    EZSP_CONFIG_RETRY_QUEUE_SIZE(0x0034),

    /**
     * Setting the new broadcast entry threshold.
     */
    EZSP_CONFIG_NEW_BROADCAST_ENTRY_THRESHOLD(0x0035),

    /**
     * The length of time, in seconds, that a trust center will store a transient link key that a
     * device can use to join its network. A transient key is added with a call to
     * emberAddTransientLinkKey. After the transient key is added, it will be removed once this
     * amount of time has passed. A joining device will not be able to use that key to join until it is
     * added again on the trust center. The default value is 300 seconds, i.e., 5 minutes.
     */
    EZSP_CONFIG_TRANSIENT_KEY_TIMEOUT_S(0x0036),

    /**
     * The number of passive acknowledgements to record from neighbors before we stop
     * re-transmitting broadcasts.
     */
    EZSP_CONFIG_BROADCAST_MIN_ACKS_NEEDED(0x0037),

    /**
     * The length of time, in seconds, that a trust center will allow a Trust Center (insecure)
     * rejoin for a device that is using the well-known link key. This timeout takes effect once
     * rejoins using the well-known key has been allowed. This command updates the
     * emAllowTcRejoinsUsingWellKnownKeyTimeoutSec value.
     */
    EZSP_CONFIG_TC_REJOINS_USING_WELL_KNOWN_KEY_TIMEOUT_S(0x0038);

    /**
     * A mapping between the integer code and its corresponding type to
     * facilitate lookup by code.
     */
    private static Map<Integer, EzspConfigId> codeMapping;

    private int key;

    static {
        codeMapping = new HashMap<Integer, EzspConfigId>();
        for (EzspConfigId s : values()) {
            codeMapping.put(s.key, s);
        }
    }

    private EzspConfigId(int key) {
        this.key = key;
    }

    /**
     * Lookup function based on the EmberStatus type code. Returns null if the
     * code does not exist.
     *
     * @param code the code to lookup
     * @return enumeration value of the alarm type.
     */
    public static EzspConfigId getEzspConfigId(int code) {
        if (codeMapping.get(code) == null) {
            return UNKNOWN;
        }

        return codeMapping.get(code);
    }

    /**
     * Returns the EZSP protocol defined value for this enumeration.
     *
     * @return the EZSP protocol key
     */
    public int getKey() {
        return key;
    }
}
